<?php
/**
 * Styles paramétrés communs à toutes les pages
 *
 * Usage : S'emploie à l'intérieur d'un tag link, exemples :
 * 
 * <link rel="stylesheet" type="text/css" href="css/style-ecran.php?modele=2" />
 * <link rel="stylesheet" type="text/css" href="css/style-menu.php?iebugs" />
 * <link rel="stylesheet" type="text/css" 
 *       href="css/style-menu.php?iebugs&modele=acad" />
 *  
 * Accepte deux paramètres optionels en méthode GET : 
 *  - iebugs : pour activer les hacks de ce type de navigateur.
 *  - modele : accepte des caractères a-z et 0 à 9, pour spécifier un modèle
 *             de couleurs, au format fichier .INI, s'appelant : css-<nom-modele>.ini
 * 
 * Quelques modèles de couleurs sont fournis avec la maquette. 
 * 
 * Nécessite le module http pour la classe dirapHttpIMS 
 * 
 * @package    Maquette 
 * @author     Luc Chatefau <luc.chatefau@ac-poitiers.fr>
 * @author     Philippe MARASSE <philippe.marasse@ac-poitiers.fr>
 * @copyright  2006 D.I.R. Académie de Poitiers
 * @license    http://www.opensource.org/licenses/gpl-license.php
 * @version    $Id: style-ecran.php,v 1.6 2007/08/29 15:28:18 philippe Exp $
 */
require_once('../classes/http/class.dirapHttpIMS.inc.php');

header('Content-Type: text/css; charset=utf-8');

// Prise en charge des requêtes If-Modified-Since
$ims = dirapHttpIMS::getInstance();

// Timestamp de base : celui de ce fichier
$ims->setTimestamp(filemtime(__FILE__));

$baseCss = array();
if (isset($_GET['modele'])) {
    $modele = preg_replace('/[^a-z0-9]+/','',$_GET['modele']);
    $filename = 'modeles/css-'.$modele.'.ini';
    if (file_exists($filename)) {
        // Prise en compte du timestamp du modèle
        $ims->setNewerTimestamp(filemtime($filename));
        
        // Avant le parse, on stoppe le traitement si le fichier n'a pas été modifié
        $ims->doIfModifiedSince();
        
        $baseCss = parse_ini_file($filename,true);            
        echo "/* Modèle chargé : $filename */\n";
    }
}

// Stoppe l'exécution si le fichier n'a pas été modifié.
$ims->doIfModifiedSince();

// Section [base]
if (! isset($baseCss['base'])) { $baseCss['base'] = array(); }
if (! isset($baseCss['base']['font-size'])) {
    $baseCss['base']['font-size'] = '10pt';
}
if (! isset($baseCss['base']['color'])) {
    $baseCss['base']['color'] = '#000000';
}
if (! isset($baseCss['base']['bgcolor'])) {
    $baseCss['base']['bgcolor'] = '#FFFFFF';
}
if (! isset($baseCss['base']['hover-color'])) {
    $baseCss['base']['hover-color'] = '#E33C3C';
}
if (! isset($baseCss['base']['border-color'])) {
    $baseCss['base']['border-color'] = '#001B94';
}
    
// Section [titre]
if (! isset($baseCss['titre'])) { $baseCss['titre'] = array(); }
if (! isset($baseCss['titre']['bgcolor'])) { 
    $baseCss['titre']['bgcolor'] = '#cec'; 
}
if (! isset($baseCss['titre']['border-color'])) {
    $baseCss['titre']['border-color'] = '#001B94';
}
    
// Section [bandeau]
if (! isset($baseCss['bandeau'])) { $baseCss['bandeau'] = array(); }
if (! isset($baseCss['bandeau']['header-color'])) { 
    $baseCss['bandeau']['header-color'] = '#059400'; 
}
if (! isset($baseCss['bandeau']['banniere-color'])) { 
    $baseCss['bandeau']['banniere-color'] = '#C3E7D1'; 
}
if (! isset($baseCss['bandeau']['banniere-bgcolor'])) { 
    $baseCss['bandeau']['banniere-bgcolor'] = '#059400'; 
}
if (! isset($baseCss['bandeau']['banniere-link-color'])) { 
    $baseCss['bandeau']['banniere-link-color'] = '#059400'; 
}
if (! isset($baseCss['bandeau']['banniere-hover-color'])) { 
    $baseCss['bandeau']['banniere-hover-color'] = '#059400'; 
}
if (! isset($baseCss['bandeau']['ver-color'])) { 
    $baseCss['bandeau']['ver-color'] = 'white'; 
}
    
// Section [button], Styles des éléments de formulaires
if (! isset($baseCss['button'])) { $baseCss['button'] = array(); }
if (! isset($baseCss['button']['bgcolor'])) { 
    $baseCss['button']['bgcolor'] = '#eee'; 
}
if (! isset($baseCss['button']['border-color'])) { 
    $baseCss['button']['border-color'] = '#eee'; 
}
if (! isset($baseCss['button']['bevel-color'])) { 
    $baseCss['button']['bevel-color'] = '#eee'; 
}

if (! isset($baseCss['button'])) { $baseCss['button'] = array(); }
if (! isset($baseCss['button']['th-color'])) { 
    $baseCss['button']['th-color'] = '#000000'; 
}
if (! isset($baseCss['button']['th-bgcolor'])) { 
    $baseCss['button']['th-bgcolor'] = '#def'; 
}
    
// Section messages
if (! isset($baseCss['msg'])) { $baseCss['msg'] = array(); }

// Styles de la bannière de message de succès
if (! isset($baseCss['msg']['ok-color'])) { 
    $baseCss['msg']['ok-color'] = "black"; 
}
if (! isset($baseCss['msg']['ok-bgcolor'])) { 
    $baseCss['msg']['ok-bgcolor'] = "#bfb"; 
}
if (! isset($baseCss['msg']['ok-border-color'])) { 
    $baseCss['msg']['ok-border-color'] = "#8c8"; 
}
    
// Styles de la bannière de message d'info
if (! isset($baseCss['msg']['info-color'])) { 
    $baseCss['msg']['info-color'] = "black"; 
}
if (! isset($baseCss['msg']['info-bgcolor'])) { 
    $baseCss['msg']['info-bgcolor'] = "#ddf"; 
}
if (! isset($baseCss['msg']['info-border-color'])) { 
    $baseCss['msg']['info-border-color'] = "#aaf"; 
}

// Styles de la bannière de message d'erreur
if (! isset($baseCss['msg']['err-color'])) { 
    $baseCss['msg']['err-color'] = "black"; 
}
if (! isset($baseCss['msg']['err-bgcolor'])) { 
    $baseCss['msg']['err-bgcolor'] = "#fcc"; 
}
if (! isset($baseCss['msg']['err-border-color'])) { 
    $baseCss['msg']['err-border-color'] = "#faa"; 
}
    
?>
@import 'style-menu.php<?php 
    if (isset($_SERVER["QUERY_STRING"])) {
        echo '?'.$_SERVER["QUERY_STRING"];
    }
?>';

body {
    color: <?php echo $baseCss['base']['color']; ?>;
    background-color: <?php echo $baseCss['base']['bgcolor'] ?>;
    font-family: sans-serif, Arial, Helvetica;
    font-size: <?php echo $baseCss['base']['font-size']; ?>;
    text-align: justify;
    text-indent: 0pt;
}

p {
    font-family: sans-serif, Arial, Helvetica;
    font-size: <?php echo $baseCss['base']['font-size']; ?>;
    text-align: justify;
    text-indent: 0pt;
}

h1 {
    font-family: sans-serif, Arial, Helvetica;
    font-size: 160%;
    text-align: left;
    text-indent: 0pt;
    color: <?php echo $baseCss['base']['color']; ?>;
    background-color: <?php echo $baseCss['titre']['bgcolor']; ?>;
    border-bottom: 3px solid <?php echo $baseCss['titre']['border-color']; ?>;
}

h2 {
    font-family: sans-serif, Verdana, Arial, Helvetica;
    font-size: 130%;
    text-align: left;
    text-indent: 1em;
    color: <?php echo $baseCss['base']['color']; ?>;
    background-color: <?php echo $baseCss['titre']['bgcolor']; ?>;
    border-bottom: 1px solid <?php echo $baseCss['titre']['border-color']; ?>;
}

h3 {
    font-family: sans-serif, Verdana, Arial, Helvetica;
    font-size: 115%;
    text-align: left;
    text-indent: 2em;
    margin-top: .75em;
    margin-bottom: .25em;
    color: <?php echo $baseCss['base']['color']; ?>;
    background-color: <?php echo $baseCss['titre']['bgcolor']; ?>;
}

li {
    text-indent: 0pt;
}

/* le spacer */
hr {
    clear: both;
    visibility: hidden;
}

/* Les liens hypertextes */
a {
    text-decoration: none;
}

a:link {
    color: <?php echo $baseCss['base']['color']; ?>;
    background-color: <?php echo $baseCss['base']['bgcolor'] ?>;
    text-decoration: none;
}

a:visited {
    color: <?php echo $baseCss['base']['color']; ?>;
    background-color: <?php echo $baseCss['base']['bgcolor'] ?>;
    text-decoration: none;
}

a:hover {
    color: <?php echo $baseCss['base']['hover-color']; ?>;
    background-color: <?php echo $baseCss['base']['bgcolor'] ?>;
    text-decoration: underline;
}

a img {
    border: none;
    vertical-align: baseline;
}

/* Eléments de formulaires */
input {
    text-indent: 0pt;
    border: 1px solid <?php echo $baseCss['base']['border-color']; ?>;
}

input.radio, input.checkbox {
    border: none;
}

button, input.button {
    text-indent: 0pt;
    border-top: 2px solid <?php echo $baseCss['button']['bevel-color']; ?>;
    border-left: 2px solid <?php echo $baseCss['button']['bevel-color']; ?>;
    border-bottom: 2px solid <?php echo $baseCss['button']['border-color']; ?>;
    border-right: 2px solid <?php echo $baseCss['button']['border-color']; ?>;
    color: <?php echo $baseCss['base']['color']; ?>;
    background-color: <?php echo $baseCss['button']['bgcolor']; ?>;
    margin: 0 0 0 .25em;
    padding: 1px;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: <?php echo $baseCss['base']['font-size']; ?>;
    /*   cursor: pointer; */
}

button:active, input.button:active {
    border-top: 2px solid <?php echo $baseCss['button']['border-color']; ?>;
    border-left: 2px solid <?php echo $baseCss['button']['border-color']; ?>;
    border-bottom: 2px solid <?php echo $baseCss['button']['bevel-color']; ?>;
    border-right: 2px solid <?php echo $baseCss['button']['bevel-color']; ?>;
}

select {
    border: 1px solid <?php echo $baseCss['base']['border-color']; ?>;
}

textarea {
    border: 1px solid <?php echo $baseCss['base']['border-color']; ?>;
    font-family: sans-serif, Verdana, Arial, Helvetica;
    font-size: <?php echo $baseCss['base']['font-size']; ?>;
    text-align: justify;
    text-indent: 0pt;
}

fieldset {
    border: 1px solid <?php echo $baseCss['base']['border-color']; ?>;
    margin-right: 1em;
}

label {
    font-style: italic;
}

/* Eléments de formulaire dans un tableau */
table input {
    border: 1px solid <?php echo $baseCss['base']['border-color']; ?>;
}

table select {
    border: 1px solid <?php echo $baseCss['base']['border-color']; ?>;
}

table textarea {
    border: 1px solid <?php echo $baseCss['base']['border-color']; ?>;
    font-family: sans-serif, Verdana, Arial, Helvetica;
    font-size: <?php echo $baseCss['base']['font-size']; ?>;
    text-align: justify;
    text-indent: 0pt;
}

table.login input {
    border: 1px solid <?php echo $baseCss['base']['border-color']; ?>;
}

table a, table a:link, table a:visited, table a:hover {
    background-color: transparent;
}

/* Tableaux */
table {
    border: 1px solid <?php echo $baseCss['base']['border-color']; ?>;
    margin: .5ex;
    color: <?php echo $baseCss['base']['color']; ?>;
    background-color: <?php echo $baseCss['base']['bgcolor'] ?>;
    border-collapse: collapse;
}

fieldset table {
    border: none;
    padding: 0.5em;
}

td {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: <?php echo $baseCss['base']['font-size']; ?>;
    font-weight: normal;
    text-align: justify;
    vertical-align: top;
    padding: 1px 0.5em 1px 0.5em;
}

/* Classe de titre - nowrap */
td.right {
    text-align: right;
    white-space: nowrap;
}

td.pair {
    color: <?php echo $baseCss['base']['color']; ?>;
    background-color: <?php echo $baseCss['button']['bgcolor'] ?>;
}

td.impair {
    color: <?php echo $baseCss['base']['color']; ?>;
    background-color: <?php echo $baseCss['base']['bgcolor'] ?>;
}

tr.pair {
    color: <?php echo $baseCss['base']['color']; ?>;
    background-color: <?php echo $baseCss['button']['bgcolor'] ?>;
}

tr.impair {
    color: <?php echo $baseCss['base']['color']; ?>;
    background-color: <?php echo $baseCss['base']['bgcolor'] ?>;
}

th {
    border-bottom: 1px solid <?php echo $baseCss['base']['border-color']; ?>;
    text-align: center;
    vertical-align: bottom;
    color: <?php echo $baseCss['button']['th-color']; ?>;
    background-color: <?php echo $baseCss['button']['th-bgcolor'] ?>;
    white-space: nowrap;
    padding: 1px 0.5em 1px 0.5em;
}

th.right {
    text-align: right;
    vertical-align: top;
    border-bottom: none;
}

tr.impair th.right {
    color: <?php echo $baseCss['base']['color']; ?>;
    background-color: <?php echo $baseCss['base']['bgcolor'] ?>;
}

tr.pair th.right {
    color: <?php echo $baseCss['base']['color']; ?>;
    background-color: <?php echo $baseCss['button']['bgcolor'] ?>;
}

address {
    text-align: right;
    font-size: 80%;
    font-style: italic;
    font-weight: normal;
}

/* Entête d'informations utilisateur */
div#entete {
    text-align: left;
    margin-top: 0;
    margin-left: 0;
    margin-right: 0;
    color: <?php echo $baseCss['bandeau']['header-color']; ?>;
    background-color: <?php echo $baseCss['base']['bgcolor'] ?>;
    font-size: 12px;
    font-weight: bold;
    padding: 0 0 1px 0;
    border-bottom: 1px solid <?php echo $baseCss['base']['border-color']; ?>;
}

/* Bannière d'application */
div#banniere {
    height: 65px;
    margin-top: 0px;
    margin-right: 0;
    padding: 0px;
    font-size: 16pt;
    font-weight: normal;
    /* border-bottom: 1px solid <?php echo $baseCss['base']['border-color']; ?>; */
    /* background: url('../logos/fond-degrade.png'); */
    color: <?php echo $baseCss['bandeau']['banniere-color']; ?>;
    background-color: <?php echo $baseCss['bandeau']['banniere-bgcolor'] ?>;
    background-repeat: repeat-y;
}

/* Version de l'application */
div#version {
    float: right;
    font-size: 12px;
    color: <?php echo $baseCss['bandeau']['ver-color']; ?>;
    background-color: inherit;
    font-weight: bold;
}

/* Nom de l'application */
div#nomappli {
    position: relative;
    margin: 0 0 0 70px;
    padding: 0;
    font-size: 14pt;
    font-weight: bold;
    line-height: 20px;
    color: inherit;
    background-color: transparent;
}

/* Titre de la page en cours */
div#titrepage {
    color: inherit;
    background-color: transparent;
    position: relative;
    margin: 0 0 0 70px;
    font-size: 18pt;
    line-height: 30px;
    padding: 0;
    text-align: center;
}

/* Logo de l'académie */
div#banniere .logo {
    float: left;
    padding: 0;
}

/* Position de la div de barre de navigation (position actuelle dans l'appli) */
div#pos {
    position: relative;
    margin-left: 70px;
    font-size: <?php echo $baseCss['base']['font-size']; ?>;
    font-weight: bold;
    color: inherit;
    background-color: transparent;
    line-height: 11px;
/*    clear: both; */
}

/* Liens éventuellement présents dans la bannière (en général dans la div #pos) */
#banniere a {
    text-decoration: none;
    padding: 1px 2px 1px 2px;
}

#banniere a:link {
    color: <?php echo $baseCss['bandeau']['banniere-link-color']; ?>;
    background-color: <?php echo $baseCss['bandeau']['banniere-bgcolor'] ?>;
    text-decoration: none;
}

#banniere a:visited {
    color: <?php echo $baseCss['bandeau']['banniere-link-color']; ?>;
    background-color: <?php echo $baseCss['bandeau']['banniere-bgcolor'] ?>;
    text-decoration: none;
}

#banniere a:hover {
    color: <?php echo $baseCss['bandeau']['banniere-hover-color']; ?>;
    background-color: <?php echo $baseCss['bandeau']['banniere-hover-bgcolor'] ?>;
    text-decoration: underline;
}


/* Conteneur global - pour filet à droite */
div#conteneur {
    color: <?php echo $baseCss['bandeau']['banniere-color']; ?>;
    background-color: <?php echo $baseCss['bandeau']['banniere-bgcolor'] ?>;
    margin-left: 0;
    margin-right: 0;
    padding: 0 40px 0 0;
}

/* Contenu global - div principale*/
div#contenu {
    color: <?php echo $baseCss['base']['color']; ?>;
    background-color: <?php echo $baseCss['base']['bgcolor'] ?>;
    margin: 0;
    padding: 0 0 1em 0;
    overflow: hidden;
    /* 1em pour pousser les mentions légales en étendant le conteneur */
}

/* Message d'erreur, d'information éventuel */
div.info {
    background: <?php echo $baseCss['msg']['info-bgcolor']; ?> url('../icones/info.png') 0.5em 0px no-repeat;
    color: <?php echo $baseCss['msg']['info-color']; ?>;
    border-top: 1px solid <?php echo $baseCss['msg']['info-border-color']; ?>;
    border-bottom: 1px solid <?php echo $baseCss['msg']['info-border-color']; ?>;
    font-size: 90%;
    margin: 2px 0;
    padding-left: 2.5em;
    /*  visibility: hidden;
  display: none; */
}

div.erreur {
    background: <?php echo $baseCss['msg']['err-bgcolor']; ?> url('../icones/error.png') 0.5em 0px no-repeat;
    color: <?php echo $baseCss['msg']['err-color']; ?>;
    border-top: 1px solid <?php echo $baseCss['msg']['err-border-color']; ?>;
    border-bottom: 1px solid <?php echo $baseCss['msg']['err-border-color']; ?>;
    font-size: 90%;
    margin: 2px 0;
    padding-left: 2.5em;
    /*  visibility: hidden;
  display: none; */
}

div.succes {
    height: 18px;
    background: <?php echo $baseCss['msg']['ok-bgcolor']; ?> url('../icones/success.png') 0.5em 2px no-repeat;
    color: <?php echo $baseCss['msg']['ok-color']; ?>;
    border-top: 1px solid <?php echo $baseCss['msg']['ok-border-color']; ?>;
    border-bottom: 1px solid <?php echo $baseCss['msg']['ok-border-color']; ?>;
    font-size: 90%;
    margin: 2px 0;
    padding-top: 2px;
    padding-left: 2.5em;
    /*  visibility: hidden;
  display: none; */
}

/* Mentions légales */
div#legal {
    color: <?php echo $baseCss['bandeau']['banniere-bgcolor']; ?>;
    background-color: <?php echo $baseCss['base']['bgcolor'] ?>;
    border-top: 1px solid <?php echo $baseCss['bandeau']['banniere-bgcolor']; ?>;
    font-size: 90%;
    margin: 0;
    text-align: center;
    padding-left: 2.5em;
}

/* Pour contenus larges */
div.xxl {
   overflow: auto;
   margin: .5ex;
   padding: 0;
}

